package object;

public class ToStringDemo {
    public static void main(String[] args) {
        Ship ship = new Ship();
        System.out.println(ship);
        Boat boat = new Boat();
        System.out.println(boat);
        Bomb bomb = new Bomb(4,5,6,7);
        System.out.println(bomb);
        Mine mine = new Mine(1,2,3,4);
        System.out.println(mine);
        Torped torped = new Torped(8,5,4,2);
        System.out.println(torped);
    }
}
class Bomb {
    private double x;
    private double y;
    private double w;
    private double h;

    public Bomb(double x, double y, double w, double h) {
        this.x = x;
        this.y = y;
        this.w = w;
        this.h = h;
    }

    @Override
    public String toString() {
        return "Bomb{" +
                "x=" + x +
                ", y=" + y +
                ", w=" + w +
                ", h=" + h +
                '}';
    }
}

class Mine{
    private double a;
    private double b;
    private double c;
    private double d;

    public Mine(double a, double b, double c, double d) {
        this.a = a;
        this.b = b;
        this.c = c;
        this.d = d;
    }

    @Override
    public String toString() {
        return "Mine{" +
                "a=" + a +
                ", b=" + b +
                ", c=" + c +
                ", d=" + d +
                '}';
    }
}

class Torped{
    private double a;
    private double b;
    private double c;
    private double d;

    public Torped(double a, double b, double c, double d) {
        this.a = a;
        this.b = b;
        this.c = c;
        this.d = d;
    }

    @Override
    public String toString() {
        return "Torped{" +
                "a=" + a +
                ", b=" + b +
                ", c=" + c +
                ", d=" + d +
                '}';
    }
}


class Ship{

}
class Boat{
    public String toString(){
        return "小船";
    }
}